package com.hzc.springchan.config.envcheck;

import com.hzc.springchan.service.IEnvironmentCheckService;
import com.hzc.springchan.util.LogUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

import javax.annotation.PostConstruct;

/**
 * 环境检查配置类
 * @author chen990627
 * @date 2022/10/13
 */
@Configuration
@DependsOn({"environmentCheckService"})
public class EnvironmentCheck {

    private IEnvironmentCheckService environmentCheckService;

    public EnvironmentCheck(IEnvironmentCheckService environmentCheckService) {
        this.environmentCheckService = environmentCheckService;
    }

    @PostConstruct  //在方法上加该注解会在项目启动的时候执行该方法，也可以理解为在spring容器初始化的时候执行该方法。
    public void environmentCheck() {

        LogUtils.info(this, "------------------------environment check start----------------------");
        environmentCheckService.healthCheck();
        LogUtils.info(this, "------------------------environment check end----------------------");
    }
}
